import numpy as np

a = np.array([3, 1, 2])
b = np.array([5, 1, 4])
c = np.array([1, 9, 7])

indices = np.lexsort((a, b, c))
sorted_array = np.vstack((a[indices], b[indices], c[indices]))

print(sorted_array)
